package xzr1;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Student{
    private String name;
    private int age;
    private double cj;
    

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public double getCj() {
        return cj;
    }

    public void setCj(double cj) {
        this.cj = cj;
    }
}
public class Work3 {
    public static void main(String[] args) {
        List<Student> list = new ArrayList<Student>();
        Scanner scanner = new Scanner(System.in);
        for (int i = 0; i <10; i++) {
            Student student = new Student();
            System.out.println("输入第"+(i+1)+"个同学姓名:>");
            String name = scanner.next();
            System.out.println("输入第"+(i+1)+"个同学年龄:>");
            int age = scanner.nextInt();
            System.out.println("输入第"+(i+1)+"个同学成绩:>");
            double  chengji = scanner.nextDouble();

            student.setName(name);
            student.setAge(age);
            student.setCj(chengji);
            list.add(student);
        }
        double sum = 0;
        int count = 0;
        for (Student s:list) {
            if(s.getName().charAt(0) == '张'){
                sum+=s.getCj();
                count++;
            }
        }
        System.out.println("所有姓张同学的平均成绩为"+sum/count);
    }
}
